<template>
  <div class="hero" :style="back">
    <div class="hero-text">
      <h1>只要来日可期，今天就值得欣喜。</h1>
      <p>Today is a day to be happy, as long as the future is in sight.</p>
    </div>
    <div class="hero-bot"></div>
  </div>
  <div class="main">
    <div class="main-left">
      <div class="cent">
        <p class="cent-title">
          实现前端开发几个常用技巧
        </p>
        <p class="cent-brief">
          定时器轮询监听readyState的状态，如果是 complete 或者 interactive 说明文件加载完成。
        </p>
      </div>
    </div>
    <div class="main-right">
      <img :src="image[0]" alt="">
      <p>跃跃呀</p>
      <p>web开发工程师</p>
      <p>努力学习</p>
    </div>
  </div>
</template>

<script lang="ts">
import { ref } from "vue";
export default {
  name: "index",
  setup() {
    const image = ref<string[]>([
      require("@/assets/img/1.jpg"),
      require("@/assets/img/2.jpg"),
      require("@/assets/img/3.png"),
      require("@/assets/img/4.jpg"),
      require("@/assets/img/5.jpg"),
      require("@/assets/img/6.jpg"),
      require("@/assets/img/7.jpg"),
      require("@/assets/img/8.jpg"),
      require("@/assets/img/9.jpg"),
      require("@/assets/img/10.png"),
      require("@/assets/img/11.jpg"),
      require("@/assets/img/12.jpg"),
      require("@/assets/img/13.jpg"),
      require("@/assets/img/14.jpg"),
      require("@/assets/img/15.jpg")
    ]);
    const index = Math.floor(Math.random() * 15 + 1);
    const back = `background: rgba(0, 0, 0, 0.3) url(${
      image.value[index - 1]
    }) center center / cover no-repeat;`;

    return {
      image,
      back
    };
  }
};
</script>

<style scoped lang="scss">
.hero {
  text-align: center;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  padding: 0 20px;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  &-text {
    color: #fff;
    font-family: Regular, cursive;
    h1 {
      transition: all 0.25s ease-in-out 0.04s;
      transform: translateY(0px);
      opacity: 1;
      font-size: 3.5rem;
    }
    p {
      font-size: 1.5rem;
    }
  }
  &-bot {
  }
}
.main{
  min-width: 1200px;
  margin: 20px 0;
  display: flex;
  justify-content: space-around;
  &-left{
    width: 60%;
    padding:0 50px;
    .cent{
      width: 100%;
      box-shadow: 0px 0px 2px 5px rgb(229, 226, 226);
      border-radius: 10px;
      margin-bottom: 40px;
      &-brief{
        padding: 0 10px;
        text-align: left;
      }
      &-title{
        font-size: 22px;
        font-weight: bold;
        text-align: left;
        line-height: 30px;
        padding: 15px 10px;
      }
    }
  }
  &-right{
    width: 20%;
    border-left: 1px solid rgba(136, 136, 136, 0.151);
    img{
      width: 100px;
      height: 100px;
      border-radius: 50%;
    }
    p{
      font-size: 15px;
      color: #666;
      line-height: 30px;
    }
  }
}
</style>
